﻿using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.Web.Infrastructure.Formatters
{
	public static class DateSentFormatter
	{
		public static string FormatSentDate(EmailMessage msg)
		{
			if (msg == null)
				return "";

            var result = new List<string>();

            if (msg.PlatinumSendDate.HasValue)
            {
                result.Add("Platinum: " + msg.PlatinumSendDate.Value.ToShortDateString() + (msg.PlatinumSendStatus == (byte)SendStatus.Success ? "+" : ""));
            }

            if (msg.GoldSendDate.HasValue)
            {
                result.Add("Gold: " + msg.GoldSendDate.Value.ToShortDateString() + (msg.GoldSendStatus == (byte)SendStatus.Success ? "+" : ""));
            }

            if (msg.SilverSendDate.HasValue)
            {
                result.Add("Silver: " + msg.SilverSendDate.Value.ToShortDateString() + (msg.SilverSendStatus == (byte)SendStatus.Success ? "+" : ""));
            }

            if (msg.FreeSendDate.HasValue)
            {
                result.Add("Free: " + msg.FreeSendDate.Value.ToShortDateString() + (msg.FreeSendStatus == (byte)SendStatus.Success ? "+" : ""));
            }

            return string.Join("<br/>", result.ToArray());
		}

        public static string FormatMinAccessLevel(Newsletter news)
        {
            return (news != null ? ((SubscriptionType)news.MinAccessLevelOriginal).ToString() : "");
        }
        public static string FormatMinAccessLevel(News news)
        {
            return (news != null ? ((SubscriptionType)news.MinAccessLevel).ToString() : "");
        }
	}
}
